package chatGUI;

import ChatController.ChatController;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.net.SocketException;
import java.net.UnknownHostException;
import javax.swing.*;

public class ChatWindowFrame extends JFrame {

    JMenuBar menuBar;
    JMenu fileMenu, helpMenu;
    JMenuItem closeMenuItem, aboutMenuItem;

    public ChatWindowFrame() throws SocketException {
        super();

        menuBar = new JMenuBar();
        aboutMenuItem = new JMenuItem("About");
        aboutMenuItem.setMnemonic('a');
        aboutMenuItem.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                JOptionPane.showMessageDialog(null, "This Chat System is presented by Georges Aoun and Anthony Doutre." + "\n"
                        + " Version 1 supports exchange of messages and files only.", "About this Chat System", 1);

            }
        });

        fileMenu = new JMenu("File");
        fileMenu.setMnemonic('f');
        helpMenu = new JMenu("Help");
        helpMenu.setMnemonic('h');
        closeMenuItem = new JMenuItem("Exit");
        closeMenuItem.setMnemonic('e');
        closeMenuItem.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent arg0) {

                try {
                    chatNI.ChatNI.sendBye();
                } catch (SocketException err) {
                    System.err.print(err);
                } catch (UnknownHostException u) {
                    System.err.print(u);
                }
                System.exit(1);
            }
        });

        helpMenu.add(aboutMenuItem);
        fileMenu.add(closeMenuItem);
        menuBar.add(fileMenu);
        menuBar.add(helpMenu);
        setJMenuBar(menuBar);
    }

   
}
